package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CommentPageQueryDTO;
import com.sky.entity.Comment;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {

    /**
     * 根据博客id查评论
     * @param commentPageQueryDTO
     * @return
     */
    @Select("select  * from comment where  blog_id =#{blogId} and game_forum.comment.parent_id=0 order by game_forum.comment.parent_id,game_forum.comment.id")
    Page<Comment> getByBlogIdParent(CommentPageQueryDTO commentPageQueryDTO);

    /**
     * 增加评论
     * @param comment
     */
    @AutoFill(OperationType.INSERT)
    void insert(Comment comment);

    /**
     * 根据id查评论
     * @param parentId
     */
    @Select("select * from comment where id =#{id} ")
    Comment getById(Long parentId);

    /**
     * 查询子评论
     * @param parentIds
     * @return
     */
    List<Comment> getChildernComments(List<Long> parentIds);
}
